package com.laotou99.wmsjjj.wmsjjj.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.laotou99.wmsjjj.wmsjjj.bean.vo.CUSTVO;
import com.laotou99.wmsjjj.wmsjjj.service.CUSTService;

/**
 * @category 客户控制路径
 * */
@Controller
@RequestMapping("/cust")
public class CUSTController {

	@Autowired
	CUSTService custService;
	
	
	@RequestMapping("/saveCUST")
	@ResponseBody
	public String saveCUST(CUSTVO custvo) 
	{	
		if(custvo.getStorekey()==null || 
			custvo.getStorekey().equals("")) 
		{
			return "NO STOREKEY";
		} 
		if(custService.saveCUST(custvo)) {
			return "ERROR";
		} 
		return "OK";
	}
	
	//修改客户信息
	@RequestMapping("/updateCUST")
	@ResponseBody
	public String updateCUST(CUSTVO custvo) {
		if(custvo==null) {
			return "ERROR";
		}
		if(custvo.getId()==0) {
			return "ERROR";
		}
		if(custService.updateCUST(custvo)) {
			return "ERROR";
		}
		return "OK";
	}
	
	
	//删除客户信息
	@RequestMapping("/deleteCUST")
	@ResponseBody
	public String deleteCUST(long l1) {
		if(custService.deleteCUST(l1)){
			return "ERROR";
		}
		return "OK";
	}
	
	//显示客户信息列表
	@RequestMapping("/showAllCUST")
	@ResponseBody
	public List<CUSTVO> showAllCUST(){
		List<CUSTVO> li1 = custService.showAllCUST();
		return li1;
	}
	
	@RequestMapping("/test1")
	@ResponseBody
	public String test1() {
		CUSTVO vo1 = new CUSTVO();
		vo1.setStorekey("apple");
		vo1.setCustCN("苹果电脑公司");
		System.out.println(saveCUST(vo1));
		
		return "test is output";
	}
}
